home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / Bento / FSHdr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  5.0 KB  |  167 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        FSHdr.h
  3.  
  4.     Contains:    ODFSContainer header
  5.  
  6.     Owned by:    Vincent Lo
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>     8/19/96    DH        1376276:OpenDoc corrupts document when out
  13.                                     of disk space creating draft. Changed class
  14.                                     to include mask member field.
  15.          <2>      5/1/96    JA        1213332: Force 68k alignment for persistent
  16.                                     struct.
  17.          <6>      4/7/95    EL        1225905: More ModDate stuff to container.
  18.          <5>     3/24/95    EL        1225905: Move state information such as mod
  19.                                     date from plfmFile to here
  20.          <4>     3/10/95    EL        1223465: allocate buffer on the heap.
  21.          <3>     2/10/95    VL        1205627: Added fMode to store access mode.
  22.          <2>     1/31/95    EL        1213321: Buffer the Bento file I/O.
  23.          <1>     5/27/94    VL        first checked in
  24.  
  25.     To Do:
  26.     
  27.     In Progress:
  28.         
  29. */
  30.  
  31. #ifndef _FSHDR_
  32. #define _FSHDR_
  33.  
  34. #ifndef _PLFMDEF_
  35. #include "PlfmDef.h"
  36. #endif
  37.  
  38. #ifndef _ODTYPES_
  39. #include "ODTypes.h"
  40. #endif
  41.  
  42. #ifndef _BENTOHDR_
  43. #include "BentoHdr.h"
  44. #endif
  45.  
  46. #ifndef __CM_API__
  47. #include "CMAPI.h"
  48. #endif
  49.  
  50. #ifndef __CM_API_TYPES__
  51. #include "CMAPITyp.h"
  52. #endif
  53.  
  54. #ifndef _PLFMDEF_
  55. #include "PlfmDef.h"
  56. #endif
  57.  
  58. //==============================================================================
  59. // Theory of Operation
  60. //==============================================================================
  61.  
  62. //==============================================================================
  63. // Constants
  64. //==============================================================================
  65.  
  66. extern const ODType    kODBentoFileTypeName; // = "FileCtr";
  67.  
  68. #define MininumChunkSize         0x100    /* minimum size of file space allocation    */
  69. #define DefaultChunkSize         0x800    /* default size of file space allocation    */
  70.  
  71. //==============================================================================
  72. // Scalar Types
  73. //==============================================================================
  74.  
  75. #if PRAGMA_ALIGN_SUPPORTED
  76. #pragma options align=mac68k
  77. #endif
  78.  
  79. struct ContainerLabelFmt {            /* Layout of a container label:            */
  80.  ODUByte magicBytes[8];                /* 8 bytes: the magic byte identifier    */
  81.  ODUShort flags;                    /* 2    the label flag                    */
  82.  ODUShort bufSize;                    /* 2    TOC buffer size / 1024            */
  83.  ODUShort majorVersion;                /* 2    major format version number        */
  84.  ODUShort minorVersion;                /* 2    minor format version number        */
  85.  ODULong tocOffset;                    /* 4    offset to start of TOC            */
  86.  ODULong tocSize;                    /* 4    total byte size of the TOC        */
  87. };
  88. typedef struct ContainerLabelFmt ContainerLabelFmt;
  89.  
  90. #if PRAGMA_ALIGN_SUPPORTED
  91. #pragma options align=reset
  92. #endif
  93.  
  94. //==============================================================================
  95. // Classes defined in this interface
  96. //==============================================================================
  97. class ODFSBentoHandlers;
  98.  
  99. //==============================================================================
  100. // Classes used by this interface
  101. //==============================================================================
  102. class PlatformFile;
  103.  
  104. //==============================================================================
  105. // ODFSBentoHandlers
  106. //==============================================================================
  107.  
  108. class ODFSBentoHandlers : public ODBentoHandlers
  109. {
  110. public:
  111.  
  112.     ODFSBentoHandlers(CMSession session, PlatformFile* file);
  113.     ODVMethod ~ODFSBentoHandlers();
  114.     
  115.     ODMethod void Initialize();
  116.     ODMethod CMSession GetCMSession();
  117.     
  118.     ODMethod CMRefCon OpenHandler(CMOpenMode mode);
  119.     ODMethod void CloseHandler();
  120.     ODMethod CMSize FlushHandler();
  121.     ODMethod CMSize SeekHandler(CM_LONG posOff, CMSeekMode mode);
  122.     ODMethod CMSize TellHandler();
  123.     ODMethod CMSize ReadHandler(CMPtr buffer, CMSize elementSize, CMCount theCount);
  124.     ODMethod CMSize WriteHandler(CMPtr buffer, CMSize elementSize, CMCount theCount);
  125.     ODMethod CMEofStatus EOFHandler();
  126.     ODMethod CMBoolean TruncHandler(CMSize containerSize);
  127.     ODMethod CMSize ContainerSizeHandler();
  128.     ODMethod void ReadLabelHandler(CMMagicBytes magicByteSequence,
  129.                         CMContainerFlags *flags, CM_USHORT *bufSize,
  130.                         CM_USHORT *majorVersion, CM_USHORT *minorVersion,
  131.                         CMSize *tocOffset, CMSize *tocSize);
  132.     ODMethod void WriteLabelHandler(CMMagicBytes magicByteSequence,
  133.                         CMContainerFlags flags, CM_USHORT bufSize,
  134.                         CM_USHORT majorVersion, CM_USHORT minorVersion,
  135.                         CMSize tocOffset, CMSize tocSize);
  136.     ODMethod CMValue ReturnParentValueHandler();
  137.     ODMethod CM_UCHAR* ReturnContainerNameHandler();
  138.     ODMethod CMType ReturnTargetTypeHandler(CMContainer container);
  139.     ODMethod void ExtractDataHandler(CMDataBuffer buffer,
  140.                             CMSize size, CMPrivateData data);
  141.     ODMethod void FormatDataHandler(CMDataBuffer buffer,
  142.                             CMSize size,
  143.                             CMPrivateData data);
  144.  
  145. private:
  146.  
  147.     ODMethod    void ReloadBuffer();
  148.     ODMethod    void FlushBuffer();
  149.  
  150.     CMSession    fSession;
  151.     PlatformFile*    fFile;
  152.     ODBoolean    fReverseEndian;
  153.     ODULong        fLogicalPos;
  154.     ODULong        fFileSize;
  155.     ODULong        fPhysicalFileSize;
  156.     ODULong        fWriteLimit;
  157.     ODULong        fChunkSize;
  158.     ODULong     fChunkHighBitsMask;
  159.     ODBoolean    fBufferDirty;
  160.     ODBoolean    fOpenReadOnly;
  161.     ODBoolean    fHasLabel;
  162.     ODULong        fBufferBegin;
  163.     ODSByte*    fBuffer;
  164.     ContainerLabelFmt fLabel;
  165. };
  166.  
  167. #endif // _FSHDR_